package com.dotstone.chipism.ui;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.TimePicker;

import com.dotstone.chipism.R;


/**
 * 基础选择器
 * Created by Administrator on 2016/7/18.
 */
public class MediaDialog extends AlertDialog {
    onDialogClickListener onDialogClickListener;

    public MediaDialog(Context context, onDialogClickListener onDialogClickListener) {
        super(context);
        initBaseDialogTheme();
        this.onDialogClickListener = onDialogClickListener;
    }

    protected MediaDialog(Context context, int theme) {
        super(context, theme);
        initBaseDialogTheme();
    }

    protected MediaDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        initBaseDialogTheme();
    }

    //底部全屏样式
    protected void initBaseDialogTheme() {
        /*android:windowNoTitle*/
//        dialog_time_select.xml(Window.FEATURE_NO_TITLE);
        Window window = getWindow();
        /* android:windowBackground*/
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        window.getDecorView().setPadding(0, 0, 0, 0);
        window.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;//设置宽度充满屏幕
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_media);
        TextView cancel = (TextView) findViewById(R.id.tv_cancel);
        TextView select = (TextView) findViewById(R.id.tv_select);
        TextView delete = (TextView) findViewById(R.id.tv_delete);

        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onDialogClickListener.cancel(MediaDialog.this);
            }
        });
        select.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onDialogClickListener.select(MediaDialog.this);

            }
        });
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onDialogClickListener.delete(MediaDialog.this);

            }
        });
        setCanceledOnTouchOutside(false);
        setCancelable(false);
    }

    public interface onDialogClickListener{
        void cancel(AlertDialog alertDialog);
        void select(AlertDialog alertDialog);
        void delete(AlertDialog alertDialog);
    }

}
